import java.util.*;
public class Spoj04{
	

static LinkedList<Integer>[] array;

 		public static void main (String args[]){
  
 			Scanner scanner = new Scanner(System.in);
 			int size=scanner.nextInt();
			int loops= scanner.nextInt();
 			array=new LinkedList[size+1];
 			scanner.nextLine();
 			
 			while(loops-->0){
 				int u = scanner.nextInt();
 				int v = scanner.nextInt();
 				String decision = check(u,v);
 				
	            	if(decision.equals("add")){
 					add(v,u);
 					add(u,v);
 				}
 				else if (decision.equals("notATree")){
 					System.out.println("NO");
 					break;
 				}
 				else{/*do nothing*/}
 				scanner.nextLine();
 			}
 			if(loops<0) System.out.println("YES");	
 		}
 		public static String check(int u, int v){
 
 			if(array[u]!=null){
 				Iterator i =array[u].listIterator(0);
 				while(i.hasNext()){
 					int value = ((Integer)i.next()).intValue();
 					if(value==v)return "doNotAdd";
 				}
 			}
 			
 			if(array[u]!=null && array[v]!=null) return "notATree";
 			return "add";
 		}
 		public static void add(int u, int v){
 			
             if(array[u]==null){
            	 array[u]=new LinkedList<Integer>();
            	 array[u].add(new Integer(v));
             }
             else array[u].addLast(new Integer(v));
 		}
}



